# coding: utf-8

import os
import sys
import glob
sys.path.append("....")

from utils import *

BASE_DIR, filename = os.path.split(os.path.abspath(__file__))

# 加密软件minizip路径
zip_path = '"C:\\Program Files\\7-Zip\\7z.exe"'

pa = gen_pass()

source_path = glob.glob(BASE_DIR + '/exports/*.*')

# 删除之前的zip文件
zipfile = glob.glob(BASE_DIR +"\\zipfiles\\*.zip")
for z in zipfile:
    print("delete {}".format(z))
    os.remove(z)

zf = os.path.splitext(os.path.basename(source_path[0]))[0]
zipfile_path = BASE_DIR + '/zipfiles/' + zf + '_' + pa + '.zip'
print(zipfile_path)

source_path = ' '.join(source_path)
print(source_path)

cmd = "{} a -ssw -p{} {} {}".format(zip_path, pa, zipfile_path, source_path)
os.system(cmd)

excelfile = glob.glob(BASE_DIR +"\exports\\*.*")
for z in excelfile:
    print("delete {}".format(z))
    os.remove(z)

sqlfile = glob.glob(BASE_DIR +"\sql\\*.*")
for z in sqlfile:
    print("delete {}".format(z))
    os.remove(z)
